package com.liushuang.waiwaiim.model.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

import com.liushuang.waiwaiim.model.dao.UserAccountTable;

public class UserAccountDBHelper extends SQLiteOpenHelper {
    public UserAccountDBHelper(@Nullable Context context) {
        super(context, "account.db", null, 1);
    }

    //数据库创建时调用
    @Override
    public void onCreate(SQLiteDatabase db) {

        //当创建数据库同时创建表
        db.execSQL(UserAccountTable.CREATE_TABLE);
    }

    //数据库更新时调用
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("drop table if exists " + UserAccountTable.TABLE_NAME);
        onCreate(db);
    }
}
